import java.util.Arrays;
//shell排序
public class Java_2_002 {
    public static void main(String[] args) {
        // 希尔排序
        int[] arr= {10,11,9,8,7,6,5,4,3,2,1};
        shell(arr);
    }

    public static void swap(int[] arr,int i,int j){
        int t = arr[i];
        arr[i]=arr[j];
        arr[j]= t;
    }
    public static void shell(int[] arr){
        int gap,i;
        gap=arr.length/2;
        while(true){
            for(i=gap;i<arr.length;i++){
                for(int j=i;j>=gap&&arr[j-gap]>arr[j];j-=gap)
                    swap(arr,j-gap,j);
            }
            System.out.println(Arrays.toString(arr));
            if(gap==1){
                break;
            }
            gap/=2;
        }
        System.out.println(Arrays.toString(arr));
        }

}
